package com.ijunfu.config;

import org.springframework.context.MessageSource;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.support.ResourceBundleMessageSource;
import org.springframework.web.servlet.LocaleResolver;
import org.springframework.web.servlet.i18n.CookieLocaleResolver;
import org.springframework.web.servlet.i18n.LocaleChangeInterceptor;
import org.springframework.web.servlet.i18n.SessionLocaleResolver;

import java.nio.charset.Charset;

/**
 *
 * @Title  : 国际化配置类
 * @Author : ijunfu <ijunfu@163.com>
 * @Date   : 2023/12/4 15:06
 * @Version: 1.0
 * @Motto  : 世界很大 世界很小
 *
 */
@Configuration
public class I18nConfiguration {

    /**
     * @Title  : 自定义MessageSource
     * @Param  :
     * @Return : org.springframework.context.MessageSource
     * @Author : ijunfu <ijunfu@163.com>
     * @Date   : 2023/12/4 15:59
     * @Motto  : 世界很大 世界很小
     */
    @Bean
    public MessageSource messageSource() {
        ResourceBundleMessageSource messageSource = new ResourceBundleMessageSource();
        messageSource.setBasename("i18n/message");
        messageSource.setDefaultEncoding(Charset.forName("UTF-8").name());
        return messageSource;
    }
}
